home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Mac OS Development Toolkit / Automation Essentials 2.3.0 / Host Automation Folder / SPEC Libs / TimingBasics.Lib < prev    next >
Encoding:
Text File  |  1998-03-19  |  24.5 KB  |  655 lines  |  [TEXT/MPS ]

  1. #
  2. # ****************************************************************************
  3. #
  4. #    File Name:    TimingBasics.lib
  5. #
  6. #    Contains:    Lower level timing routines
  7. #
  8. #    Written by:    KTA
  9. #
  10. #    Copyright:    © 1993-1995 by Apple Computer, Inc., all rights reserved.
  11. #
  12. # ****************************************************************************
  13. #            C h a n g e        H i s t o r y (most recent first):
  14. # ****************************************************************************
  15. #
  16. #        Vers      Date        Author        Description
  17. #        ----    --------    ------    ---------------------------------------------
  18. #        <13>     2/28/95    ML        marked
  19. #        <12>     2/14/95    KTA        Polling() -     Added BooleanFlag to FindWindow() call
  20. #        <11>     1/31/95    ML        add IvyOperations.Lib to declaration, change all ivy calls to
  21. #                                    _Ivy calls
  22. #        <10>     1/19/95    KTA        Changed the name of ExceptionHandler() to ExceptionDispatcher().
  23. #         <9>     12/6/94    ML        Added Exception Handling support
  24. #         <8>     7/13/94    ML        Added comments
  25. #         <8>     7/13/94    ML        Added comments
  26. #         <7>     6/28/94    ML        EndTimerIV() - bail out of infinite loop in endTime is
  27. #                                    continously 0
  28. #         <6>     6/23/94    ML        Move hook for MacsTiming in StartTimerIV() to before IV call
  29. #         <5>     6/20/94    ML        LogPerformanceResults() - If defined, use global kTCSetDefault
  30. #                                    instead of gApptitle in TCSStart() call
  31. #         <4>     4/18/94    ML        Added gStopTimerIVHook1, gStopTimerIVHook2 to globals
  32. #                                    declaration in StopTimerVU()
  33. #         <3>     4/15/94    KTA        Moved some tasks to MacsTimeOperations.Lib, Removed some tasks,
  34. #                                    etc.
  35. #         <2>     4/13/94    KTA        Changed gDBLogging to gTCTracking
  36. #         <1>     4/12/94    ML        Moved into Libraries project
  37. #     <1.0.6>     4/12/94    ML        added InitPerformance().  To  InitPerformance(), added
  38. #                                    SuiteStart params, pInitialMethod, pPerformanceLoggingOnly,
  39. #                                    MacsTime CDev launch and hook installation, removed
  40. #                                    gInitPerformanceHook1, remove and reset MacsTime hooks during
  41. #                                    ReplaceExist (modal disables Apple Events).  Added
  42. #                                    EndPerformance().  To EndPerformance(), added pCompletionCode,
  43. #                                    added check for MacsTime (MTControl), removed
  44. #                                    gEndPerformanceHook1, added SuiteEnd(), reset and restore
  45. #                                    gTCTracking.  Added TimedEventDescription().  Added
  46. #                                    LogPerformanceResults().  To  LogPerformanceResults(), renamed
  47. #                                    from LogPerformTCS, add support for pTCSStr, notebook printout
  48. #                                    of results.  Replace stoptimer w/stoptimerVU, replace stoptimer
  49. #                                    w/stoptimerVU, remove global gTiming.      StartTimerVU()-changed
  50. #                                    global StartTime to gStartTime, added generic hook -
  51. #                                    gStartTimerVUHook,renamed from StartTimer, use gTimedEvent
  52. #                                    instead of gTiming, only call if gTimedEvent is defined, removed
  53. #                                    MacsTiming calls (use gStartTimerVUHook instead).
  54. #                                    StartTimerIV() - don't run unless gTimedEvent is true, added
  55. #                                    gStartTimerIVHook. StopTimerIV() - don't run unless gTimedEvent
  56. #                                    true, removed gTiming, add gStopTimerIVHook1, gStopTimerIVHook2,
  57. #                                    added event description, pStopTimerHook, call
  58. #                                    LogPerformanceResults to log TCS's (whew!).
  59. #     <1.0.5>     3/29/94    KTA        FormatMilliSeconds() now handle integer values.
  60. #     <1.0.4>     3/11/94    KTA        Fixed bug in FormatMilliSeconds() and added parameter to
  61. #                                    StopTimerIV().
  62. #     <1.0.3>    11/18/93    KTA        Added ¶ character to output lines for performance for timings in
  63. #                                    VU also.
  64. #     <1.0.2>    11/18/93    KTA        Added ¶ character to output lines for performance.
  65. #        <1>         11/16/93    KTA        Created
  66. #
  67. # ****************************************************************************
  68. #
  69.  
  70.  
  71. ########################################################################
  72. #                            External libraries 
  73. #=======================================================================
  74. Libraries "Utility.Lib", 'UserInterface.Lib', 'IvyOperations.Lib', 'TCS.Lib',
  75. "ExceptionHandling.Lib", 'Ivy.vulib';
  76.  
  77.  
  78.  
  79. #########################################################################
  80. #                         InstallVUTimingMethod()
  81. #=======================================================================
  82. # Author:              KTA
  83. # Description:        Initializes the task references required to complete 
  84. #                    performance testing utilizing VU.
  85. # Parameters:        none
  86. # Returns:            Nothing 
  87. # Example:            InstallVUTimingMethod();
  88. # Assumptions        This task must be called prior to doing any performance
  89. #                    testing with SPEC S&L
  90. #=======================================================================
  91. # History:
  92. # ML    3/30/94    Changed StartTimer to StartTimerVU
  93. #########################################################################
  94. TASK InstallVUTimingMethod()
  95. begin
  96.     global gPreSelectMenuItemHook     :=     task StartTimerVU;
  97.     global gPostSelectMenuItemHook     :=     task StartTimerVU;
  98.     global gPreKeyEqHook            :=     task StartTimerVU;
  99.     global gPreSelectButtonHook     :=     task StartTimerVU;
  100.     global gPreMoveMouseHook         :=     task StartTimerVU;
  101.     global gPreSpecialKeyHook         :=     task StartTimerVU;
  102. end;
  103.  
  104.  
  105. #########################################################################
  106. #                         RemoveVUTimingMethod()
  107. #=======================================================================
  108. # Author:              KTA
  109. # Description:        Removes the the task references required to complete 
  110. #                    performance testing utilizing VU.
  111. # Parameters:        none
  112. # Returns:            Nothing 
  113. # Example:            RemoveVUTimingMethod();
  114. # Assumptions        This task can be called after to doing any performance
  115. #                    testing with SPEC S&L you want to remove any effects of 
  116. #                    the performance testing.
  117. #=======================================================================
  118. # History:
  119. #########################################################################
  120. TASK RemoveVUTimingMethod()
  121. begin
  122.     global gPreSelectMenuItemHook     :=     0;
  123.     global gPostSelectMenuItemHook     :=     0;
  124.     global gPreKeyEqHook            :=     0;
  125.     global gPreSelectButtonHook     :=     0;
  126.     global gPreMoveMouseHook         :=     0;
  127.     global gPreSpecialKeyHook         :=     0;
  128. end;
  129.  
  130. #########################################################################
  131. #                         InstallIVTimingMethod()
  132. #=======================================================================
  133. # Author:              KTA
  134. # Description:        Initializes the task references required to complete 
  135. #                    performance testing utilizing IVY.
  136. # Parameters:        none
  137. # Returns:            Nothing 
  138. # Example:            InstallIVTimingMethod();
  139. # Assumptions        This task must be called prior to doing any performance
  140. #                    testing with IVY
  141. #=======================================================================
  142. # History:
  143. # KTA     4/13/94    Changed gDBLogging to gTCTracking
  144. # KTA     4/14/94    Moved Standard file hooks to the StandardFile tasks
  145. #########################################################################
  146. TASK InstallIVTimingMethod()
  147. begin    
  148.     global gPreSpecialKeyHook := task StartTimerIV;
  149.     global gPreSelectButtonHook := task StartTimerIV;
  150.     global gPreKeyEqHook := task StartTimerIV;
  151. end;
  152.  
  153.  
  154. #########################################################################
  155. #                         RemoveIVTimingMethod()
  156. #=======================================================================
  157. # Author:              KTA
  158. # Description:        Removes the the task references required to complete 
  159. #                    performance testing utilizing IVY.
  160. # Parameters:        none
  161. # Returns:            Nothing 
  162. # Example:            RemoveIVTimingMethod();
  163. # Assumptions        This task can be called after to doing any performance
  164. #                    testing with IVY and you want to remove any effects of 
  165. #                    the performance testing.
  166. #=======================================================================
  167. # History:
  168. # KTA     4/13/94    Changed gDBLogging to gTCTracking
  169. # KTA     4/14/94    Moved Standard file hooks to the StandardFile tasks
  170. # ML    1/31/95    Use _Ivy calls
  171. #########################################################################
  172. TASK RemoveIVTimingMethod()
  173. begin
  174.     global gPreSpecialKeyHook := 0;
  175.     global gPreSelectButtonHook := 0;
  176.     global gPreKeyEqHook := 0;
  177.     _Ivy(task IVStopWaitForImage);
  178.     
  179.     #IVQuit();
  180. end;
  181.  
  182.  
  183.  
  184.  
  185. #########################################################################
  186. #                             StartTimerVU
  187. #=======================================================================
  188. # Author:              KTA/DM
  189. # Description:        Begin the Timer with VU
  190. # Parameters:        none
  191. # Returns:            none
  192. # Example:            StartTimerVU();
  193. #
  194. #    StartTimer will get called many more times than are actually timed.
  195. #    Timing will occur only if StopTimer is called and global gTimedEvent is TRUE
  196. #    gTimedEvent should also be set to the title of the timed test.
  197. #=======================================================================
  198. # History:
  199. # ML    3/30/94    changed  global StartTime to gStartTime
  200. # ML    3/30/94    Added generic hook - gStartTimerVUHook
  201. # ML    3/30/94    Renamed from StartTimer
  202. # ML    3/30/94    use gTimedEvent instead of gTiming
  203. # ML    3/30/94    only call if gTimedEvent is defined
  204. # ML    3/30/94    removed MacsTiming calls (use gStartTimerVUHook instead)
  205. #########################################################################
  206. task StartTimerVU()
  207. begin
  208.     global gStartTime, gTimedEvent, gStartTimerVUHook;
  209.     if gTimedEvent
  210.     begin
  211.         gStartTime := Timer();            # Start that Timer
  212.         if (gStartTimerVUHook)
  213.             call (gStartTimerVUHook);    # hook for MacsTime, etc.
  214.     end;
  215. end;
  216.  
  217. #########################################################################
  218. #                     StopTimerVU(polling := 1, specifier := '', pStopTimerHook := 0)
  219. #=======================================================================
  220. # Author:              DM/KTA/JH
  221. # Description:        subtracts the last time saved by StartTimerVU from the current time
  222. #                    and outputs the event name and the elapsed seconds
  223. # Parameters:        polling, specifier see Polling()
  224. #                    pStopTimerHook - name of custom task defined in calling script
  225. # Returns:            Elapsed time in secs if success, 0 if failure
  226. # Example:            ETime(time1, time2);
  227. #=======================================================================
  228. # History:
  229. # ML    3/30/94    changed  global StartTime to gStartTime
  230. # ML    3/31/94    Renamed to StopTimerVU, removed gTiming, add gStopTimerVUHook1, 
  231. #                gStopTimerVUHook2,
  232. #                remove calls to MacsTime (use gStopTimerVUHook1, gStopTimerVUHook2
  233. #                instead), added return value, assigned event description, change 
  234. #                StopTimerHook to pStopTimerHook, define ResultCode and ErrorString,
  235. #                call LogPerformanceResults to log TCS's (whew!)
  236. # KTA     4/13/94    Changed gDBLogging to gTCTracking
  237. #########################################################################
  238. task StopTimerVU(polling := 1, specifier := '', pStopTimerHook := 0) 
  239. begin
  240.     global gStartTime, gTimedEvent, gMacstimeApp, gMacsTiming, 
  241.     gStopTimerVUHook1, gStopTimerVUHook2, gAppTitle;
  242.     returnval := 0;
  243.     if (gTimedEvent)
  244.     begin
  245.  
  246.         if(polling) 
  247.             Polling(polling, specifier);
  248.  
  249.         endTime := Timer();                # Save Off the current time
  250.         
  251.         myEvent := TimedEventDescription();
  252.  
  253.         if (pStopTimerHook)
  254.             Call(pStopTimerHook);        
  255.             
  256.         if (gStopTimerVUHook1)    #    hook for MacsTime, etc.
  257.             Call (gStopTimerVUHook1, myEvent);        
  258.             
  259.         ##### Calculate the Elapsed Time, log Test Case
  260.  
  261.         if ((isUndefined(gStartTime)) or (gStartTime = 0))
  262.         begin
  263.             ResultCode := 0;
  264.             ErrorString := "the elapsed time routine didn't work - gStartTime is {gStartTime}!!!)";
  265.             ElapsedTime := 0;
  266.         end;
  267.         else 
  268.         begin
  269.             ResultCode := 1;
  270.             ErrorString := '';
  271.             ElapsedTime := ETime(gStartTime,endTime,0);
  272.             returnval := ElapsedTime;
  273.         end;
  274.         
  275.         LogPerformanceResults (ResultCode,ErrorString,ElapsedTime);
  276.         
  277.         gTimedEvent := '';    # reset
  278.         
  279.         if gStopTimerVUHook2    #    hook for MacsTime, etc.
  280.             call (gStopTimerVUHook2, myEvent);
  281.         
  282.         gStartTime := 0;
  283.  
  284.     end; # if (gTimedEvent)
  285.     return (returnval);
  286. end;
  287.  
  288. #########################################################################
  289. #                             Polling(PollMethod, Specifier)
  290. #=======================================================================
  291. # Author:              KTA
  292. # Description:        Polls until target machine is available or until specifier
  293. #                    is located/gone.
  294. # Parameters:        polling <> 0    poll before completing
  295. #                     specifier = ''    match the target when polling
  296. #                     specifier <> ''    & polling > 0
  297. #                            poll until the specifier is matched
  298. #                     specifier <> ''    & polling < 0
  299. #                            poll until the specifier is not matched
  300. # Returns:            
  301. # Example:            Polling(1, {[window t:'Untitled' o:2]});
  302. #=======================================================================
  303. # History:
  304. #    ML    8/12/93        Added support for any descriptor
  305. # KTA    2/14/95    Added BooleanFlag to FindWindow() call
  306. #########################################################################
  307. TASK Polling(PollMethod := 0, specifier := '')
  308. begin
  309.     if not (specifier) # just match the target
  310.     begin
  311.         try thisCheck := match [target t:?Mytarget]!;
  312.         catch theError
  313.             ExceptionDispatcher(theError);
  314.         while not (thisCheck)            #### Polling Generic ####
  315.         begin
  316.             try thisCheck := match [target t:?Mytarget]!;
  317.             catch theError
  318.                 ExceptionDispatcher(theError);
  319.         end;
  320.  
  321.         if (PollMethod = 2)         # This was put in for a VU bug will be removed
  322.             while not (_matchBoolean ([application]!));
  323.     end;
  324.     else     # match for the specifier
  325.     begin
  326.         if TypeOf(specifier) = 'descriptor'
  327.         begin
  328.             if descType(specifier) <> 'window'
  329.             begin                            # generalized polling method
  330.                 if(PollMethod > 0)             #### Polling - wait for descriptor ####
  331.                     while not (_matchBoolean (specifier!));
  332.                 else                          #### Polling - wait for descriptor to go away ####
  333.                 begin    #do this if PollMethod is negative
  334.                     while (_matchBoolean (specifier!));
  335.                 end;
  336.             end;
  337.         end;
  338.         if (TypeOf(specifier) <> descriptor) or (descType (specifier) = 'window')
  339.         begin
  340.         if(PollMethod > 0)             #### Polling - wait for window ####
  341.             while not (FindWindow(specifier, true)) ;
  342.         else                          #### Polling - wait for window to go away ####
  343.         begin    #do this if PollMethod is negative
  344.             while (FindWindow(specifier, true));
  345.         end;
  346.     end;
  347.     end;
  348. end;
  349.  
  350.  
  351. #########################################################################
  352. #                         StartTimerIV()
  353. #=======================================================================
  354. # Author:              KTA
  355. # Description:        Calls IVStartWaitForImage() and sets a variable <gStartTimerIV)
  356. #                     to the current the current time in milliseconds. Note: IVStopWaitForImage()
  357. #                    is called first in case IVStartWaitForImage() has already been called.
  358. # Parameters:        None
  359. # Returns:            Nothing - but sets gStartTimerIV to the currenttime in Milliseconds
  360. # Example:            StartTimerIV();
  361. # Assumptions        Ivy exists on the target machine and has been initialized.
  362. #=======================================================================
  363. # History:
  364. #    ML    3/31/94    Don't run unless gTimedEvent is true, added gStartTimerIVHook
  365. #    ML    6/23/94    Move hook for MacsTiming in StartTimerIV() to before IV call
  366. #    ML    1/31/95    Use _Ivy calls
  367. #########################################################################
  368. task StartTimerIV()
  369. begin
  370.     global gImageFile, gRect, gStartTimerIVHook, gTimedEvent, gStartTimerIV;
  371.     if gTimedEvent
  372.     begin
  373.         _Ivy(task IVStopWaitForImage);
  374.         if (gStartTimerIVHook)
  375.             call (gStartTimerIVHook);                # hook for MacsTime, etc.
  376.         gStartTimerIV := _Ivy(task IVStartWaitForImage,{gImageFile, gRect,5});
  377.     end;
  378. end;
  379.  
  380. #########################################################################
  381. #                         StopTimerIV()
  382. #=======================================================================
  383. # Author:              KTA
  384. # Description:        Calls IVGetTimeFound() and sets a variable <endTime>
  385. #                     to the current the current time in milliseconds. It then 
  386. #                    calls IVSubtractTimes() to get the difference between global
  387. #                    <gStartTimerIV> and <endTime>.  Then the IV and appleEvent overhead
  388. #                    is subtracted.
  389. # Parameters:        pWaitTime - Time to wait this can be longer than it takes the image to 
  390. #                                appear, but must not be shorter.
  391. #                    pStopTimerHook - name of custom task defined in calling script
  392. #                                
  393. # Returns:            NetTime2 - success, difference between gStartTimerIV and Endtime with overhead
  394. #                                subtracted.
  395. #                    0 - failure
  396. # Example:            StopTimerIV();
  397. # Assumptions        Ivy exists on the target machine and has been initailized.
  398. #                    Also requires that a call to StartTimerIV() was made prior to
  399. #                    calling this routine.
  400. #=======================================================================
  401. # History:
  402. # KTA    3/10/94    Added pWaitTime
  403. # ML    3/31/94    Don't run unless gTimedEvent true, removed gTiming, add gStopTimerIVHook1, 
  404. #                gStopTimerIVHook2, added event description, pStopTimerHook, 
  405. #                call LogPerformanceResults to log TCS's (whew!)
  406. # ML    4/18/94    Added gStopTimerIVHook1, gStopTimerIVHook2 to globals declaration
  407. # ML    6/27/94    bail out of infinite loop if endTime is continously 0
  408. # ML    1/31/95    Use _Ivy calls
  409. #########################################################################
  410. task StopTimerIV(pWaitTime := 10, pStopTimerHook := 0)
  411. begin
  412.     global gTimedEvent, gStopTimerIVHook1, gStopTimerIVHook2;
  413.     returnval := 0;
  414.     if (gTimedEvent)
  415.     begin
  416.         wait(pWaitTime);
  417.         endTime := IVGetTimeFound();
  418.         myEndCounter := 1;        # Initialize your counter
  419.         while (endTime = '0') # IVGetTimeFound returns a string
  420.         begin
  421.             if myEndCounter < 13    # only loop through 12 times (1 minute)
  422.             begin
  423.                 wait(5);
  424.                 endTime := _Ivy(task IVGetTimeFound);
  425.                 myEndCounter := myEndCounter + 1;
  426.             end;
  427.             else
  428.                 endTime := 0;
  429.         end;
  430.         
  431.         myEvent := TimedEventDescription();
  432.         
  433.         if (pStopTimerHook)
  434.             Call(pStopTimerHook);        
  435.             
  436.         if (gStopTimerIVHook1)    #    hook for MacsTime, etc.
  437.             Call (gStopTimerIVHook1, myEvent);    
  438.         
  439.         if (endTime) # if valid endTime
  440.         begin # if valid endTime
  441.             
  442.             ### Calculate the elapsed time
  443.             
  444.                 #println "This is global gStartTimerIV - ", global gStartTimerIV;
  445.                 #println "This is endTime - ", endTime;
  446.             TotalTime := _Ivy(task IVSubtractTimes, {endTime, global gStartTimerIV[1]});
  447.                 #println "This is TotalTime - ", TotalTime;
  448.             global gStartTimerIV := 0;    # Reset it
  449.             theRoundTrip := _Ivy(task IVCallOverhead);
  450.                 #println "    This is theRoundTrip - ", theRoundTrip;
  451.             
  452.             NetTime1 := _Ivy(task IVSubtractTimes, {TotalTime, theRoundTrip});
  453.                 #println "This is NetTime1 - ", NetTime1;
  454.             
  455.             TimeUsed := _Ivy(task IVStopWaitForImage);
  456.                 #println "    This is TimeUsed - ", TimeUsed;
  457.             
  458.             NetTime2 := _Ivy(task IVSubtractTimes, {NetTime1, TimeUsed});
  459.             ElapsedTime := FormatMilliSeconds(NetTime2);
  460.             returnval := ElapsedTime;
  461.             
  462.             LogPerformanceResults(1,,ElapsedTime);
  463.             
  464.         end; # if valid endTime
  465.         else # else endTime is invalid
  466.         begin
  467.             LogPerformanceResults(0,"Endpoint image not found");
  468.             println "WARNING - Endpoint image was not found -
  469.             check your IVY wait times";
  470.         end; # if invalid endTime    
  471.  
  472.         gTimedEvent := '';    # reset
  473.         
  474.         if (gStopTimerIVHook2)    #    hook for MacsTime, etc.
  475.             Call (gStopTimerIVHook2, myEvent);        
  476.             
  477.     end; # if (gTimedEvent)
  478.     return(returnval);
  479. end;
  480.  
  481.  
  482. #########################################################################
  483. #     LocateTheString( pTheRect, theString, theFont, theSize, theStyle  )
  484. #=======================================================================
  485. # Author:              KTA
  486. # Description:        Makes a call to IVLocateString() to locate a string with the attributes
  487. #                    of the parameters and returns the rect of the found string.
  488. # Parameters:        pTheRect - the rect to begin looking for the string in.
  489. #                    theString - the actual text of the string to look for.
  490. #                    theFont - the font title of theString.
  491. #                    theSize - the size of theString.
  492. #                    theStyle - the style of theSting.
  493. # Returns:            the rect of theString that was found on target machine.
  494. # Example:            LocateTheString({0,0,480, 640}, 'Hello World', 'Times', 10, 0);
  495. # Assumptions        Ivy exists on the target machine and has been initialized.
  496. #=======================================================================
  497. # History:
  498. # ML    1/31/95    Use _Ivy calls
  499. #########################################################################
  500. task LocateTheString( pTheRect, theString := "Stop", theFont := "Geneva", theSize := 12, theStyle := 0  )
  501. begin
  502.     resultList := _Ivy(task IVLocateString, {theString, pTheRect, theFont, theSize, theStyle});
  503.     if ( resultList = { 0, 0, 0, 0 } )
  504.     begin
  505.         println "Error - Ivy could not find, and therefore could not create the end point image.";
  506.         Exit;
  507.     end;
  508.     waitingRectangle := resultList;
  509.     return (waitingRectangle);    # return the end point rectangle.
  510. end; # LocateTheString()
  511.  
  512. #########################################################################
  513. #                 FormatMilliSeconds( pTimeInMilliseconds )
  514. #=======================================================================
  515. # Author:              KTA
  516. # Description:        Formats a time value in milliseconds by adding a decimal
  517. #                    point to seperate the integer portion from the fractional
  518. #                    portion.
  519. # Parameters:        pTimeInMilliseconds - a string or integer which is a time 
  520. #                            value in milliseconds.
  521. # Returns:            String - Formated value.
  522. # Example:            x := FormatMilliSeconds('76543');
  523. #=======================================================================
  524. # History:
  525. # KTA    3/10/94    Fixed problem when pTimeInMilliseconds was < 3 digits
  526. # KTA    3/15/94    Added support for pTimeInMilliseconds to be an integer. 
  527. #########################################################################
  528. TASK FormatMilliSeconds(pTimeInMilliseconds := '')
  529. begin
  530.     if (TypeOf(pTimeInMilliseconds) = 'integer')
  531.         pTimeInMilliseconds := NumToStr(pTimeInMilliseconds);
  532.         
  533.     IntegerPortion := 0;
  534.     LenghtOfTimeValue := card(pTimeInMilliseconds);
  535.     FormatedValue := '';
  536.     
  537.     if(LenghtOfTimeValue >= 3)
  538.     begin
  539.         IntegerPortion := LenghtOfTimeValue-3;
  540.         for i := 1 to IntegerPortion
  541.             FormatedValue := FormatedValue + pTimeInMilliseconds[i];
  542.     end;
  543.     else
  544.     begin
  545.         if(LenghtOfTimeValue = 2)
  546.             pTimeInMilliseconds := '0' + pTimeInMilliseconds;
  547.         else if (LenghtOfTimeValue = 1)
  548.             pTimeInMilliseconds := '00' + pTimeInMilliseconds;
  549.             
  550.         LenghtOfTimeValue := card(pTimeInMilliseconds);
  551.     end;
  552.     
  553.     FormatedValue := FormatedValue + '.';
  554.     
  555.     for n := (IntegerPortion +1) to LenghtOfTimeValue
  556.         FormatedValue := FormatedValue + pTimeInMilliseconds[n];
  557.         
  558.     #println "This is the FormatedValue - ", FormatedValue;
  559.     
  560.     return(FormatedValue);
  561. end;
  562.  
  563. #########################################################################
  564. #             LogPerformanceResults() 
  565. #========================================================================
  566. #
  567. # Author:        ML
  568. # Description:    Wrapper task for logging a performance result
  569. # Parameters:    pResultCode, pErrStr, pTCSVal, pTCSStr, pCommentStr, pExceptionFlag
  570. #                - see TCSEnd()
  571. # Returns:        none
  572. # Examples:        LogPerformanceResults()
  573. #========================================================================
  574. # History:
  575. # ML    3/31/94    renamed from LogPerformTCS, add support for pTCSStr,
  576. #                notebook printout of results
  577. # KTA     4/13/94    Changed gDBLogging to gTCTracking
  578. # ML    6/8/94    If defined, use global kTCSetDefault instead of gApptitle
  579. #                in TCSStart() call
  580. #########################################################################
  581. TASK LogPerformanceResults(pResultCode := '', pErrStr := '', pTCSVal := 0, 
  582. pTCSStr := '', pCommentStr := '', pExceptionFlag := '')
  583. begin
  584.     global gTimedEvent, gAppTitle, kTCSetDefault;
  585.     
  586.     # parse out gTimedEvent
  587.     
  588.     if typeof(gTimedEvent) = 'list'
  589.     # if list, first item is the TCS num, second is the event desc, third is TC string
  590.     begin
  591.         myTCNum := gTimedEvent[1];
  592.         myTimedEvent := gTimedEvent[2];
  593.         if gTimedEvent[3] 
  594.             pTCSStr := gTimedEvent[3];
  595.     end;
  596.     else
  597.     #if not a list, gTimedEvent is event desc
  598.     begin
  599.         myTCNum := 0;
  600.         myTimedEvent := gTimedEvent;
  601.     end;
  602.         
  603.     if ((kTCSetDefault = "UnknownSet") or (kTCSetDefault = 0) or (kTCSetDefault = ''))
  604.         myTCid := {myTCNum, gAppTitle, "Performance"};
  605.     else
  606.         myTCid := {myTCNum, kTCSetDefault, "Performance"};
  607.         
  608.     TCSStart (myTCid, myTimedEvent);
  609.     TCSEnd (myTCid, pResultCode, pErrStr, pTCSVal, pTCSStr, pCommentStr, pExceptionFlag);
  610.         
  611.     if (pResultCode = 1)
  612.     begin
  613.         if (pTCSStr and  (pTCSStr <> 'undefined'))
  614.             println "{myTimedEvent}    {pTCSStr} {pTCSVal}";            # this is where the printing happens for performance runs
  615.         else
  616.             println "{myTimedEvent} {pTCSVal}";            # this is where the printing happens for performance runs
  617.     end;
  618.     else
  619.     begin
  620.         if (pTCSStr and  (pTCSStr <> 'undefined'))
  621.             println "{myTimedEvent}    {pTCSStr} {pErrStr}";            # this is where the printing happens for performance runs
  622.         else
  623.             println "{myTimedEvent} {pErrStr}";            # this is where the printing happens for performance runs
  624.     end;
  625. end;
  626.  
  627. #########################################################################
  628. #             
  629. #                TimedEventDescription() 
  630. #========================================================================
  631. #
  632. # Author:        ML
  633. # Description:    Text description of timed event from gTimedEvent
  634. # Parameters:    none
  635. # Returns:        Text description of timed event
  636. # Examples:        TimedEventDescription()
  637. #========================================================================
  638. # History:
  639. #    ML    3/31/94        Created
  640. #########################################################################
  641. TASK TimedEventDescription()
  642. begin
  643.     global gTimedEvent;
  644.     returnval := 0;
  645.     if (gTimedEvent)
  646.     begin
  647.         if typeof(gTimedEvent) = 'list'
  648.         # if list, first item is the TCS num, second is the event desc
  649.             returnval := gTimedEvent[2];
  650.         else
  651.         #if not a list, gTimedEvent is event desc
  652.             returnval := gTimedEvent;
  653.     end;     # if (gTimedEvent)
  654.     return (returnval);
  655. end;